Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[keybindings] Aligned keybindings with VSCode #5326

Merged
merged 1 commit into from
Jul 16, 2019

Conversation

JPinkney
Copy link
Contributor

This PR changes keybindings to align themselves with how VSCode keybinding policy works. In VSCode, keybindings always register even if there is a conflict and the one that is last registered (and has the highest priority wins i.e. scoping). For example, if I have a keybinding that opens the terminal and that same keybinding also creates a new file, when I press that keybinding the new file will be created because it was registered last.

It also makes it so that you are able to see all keybindings registered to a command, instead of just one and implements removal rules.

Signed-off-by: Josh Pinkney joshpinkney@gmail.com

@JPinkney JPinkney requested review from benoitf and evidolob as code owners May 31, 2019 15:30
@JPinkney
Copy link
Contributor Author

@marechal-p @akosyakov Do you guys mind reviewing when you get a chance as well since you were both involved in the convo on spectrum about this 😄

@akosyakov
Copy link
Member

@JPinkney please reference fixed issue in the commit message

packages/core/src/browser/keybinding.ts Show resolved Hide resolved
this.keymaps[scope].push(binding);
this.keybindingsChanged.fire(undefined);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit on sure about it, on each fire menus and keybinding widget gets rerendered, it would be better to fire once for the whole keymap and fire once after all keybindings contributions are loaded (don't fire before at all)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marechal-p @kittaakos could you help to check whether it would affect electron perf startup

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some testing:

  • for initial load everything is good, since no menus is rendered before all initial keybindins are loaded
  • for consequent keybindings though for each binding registration top-level menus are rerendered

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested registration of duplicate and usage of duplicate keybindings + reverting them. Generally it works good, except excessive events on each change. Depending on what clients are doing it can be not so harmful, e.g. rerendering browser menus is cheap, but not sure about an electron or updating the keybinding widget with some search.

@akosyakov
Copy link
Member

I'm merging it if noone objets by the evening. If there are perf issues with electron we resolve them as follow-ups.

@kittaakos
Copy link
Contributor

kittaakos commented Jun 19, 2019

I am giving it a try now...

@kittaakos kittaakos self-requested a review June 19, 2019 12:48
Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase from the master first.

@kittaakos
Copy link
Contributor

I could not verify the performance as it is still using the old code which had the menu issues. Please rebase from the theia:master. Thank you!

@kittaakos
Copy link
Contributor

@JPinkney, please ping me if you have updated the PR and I try it again as soon as I can.

@JPinkney JPinkney force-pushed the vscode-keys3 branch 2 times, most recently from a249873 to 5ce046e Compare June 19, 2019 13:57
@JPinkney
Copy link
Contributor Author

@kittaakos I've rebased on master!

@kittaakos
Copy link
Contributor

Thank you, @JPinkney. I have verified the performance only, 👍 I did not check the code.

@akosyakov
Copy link
Member

@JPinkney please rebase and let's merge it

@akosyakov
Copy link
Member

I'm rebasing and merging it.

@vince-fugnitto
Copy link
Member

Originally #5621 (comment)

It seems to work correctly, but the reset code in the keybindings-widget needs to be adjusted.
It looks like when the keybinding resets (goes back to its default value), the removal rules are not removed from the keymaps.json.

Example:

  1. update a command's keybinding.
[
    {
        "command": "core.close.tab",
        "keybinding": "alt+a",
        "context": ""
    },
    {
        "command": "-core.close.tab",
        "keybinding": "alt+w",
        "context": ""
    }
]
  1. Perform a reset (the following remains in the keymaps.json).
[
    {
        "command": "-core.close.tab",
        "keybinding": "alt+w",
        "context": ""
    }
]

This means that I will no longer be able to use the keybinding alt+w for Close Tab since it is part of the removal rule.

@akosyakov
Copy link
Member

@vince-fugnitto please take care of reviewing it after @JPinkney addresses the issue

@vince-fugnitto
Copy link
Member

@vince-fugnitto please take care of reviewing it after @JPinkney addresses the issue

Sure! :)

@akosyakov akosyakov added keybindings issues related to keybindings vscode issues related to VSCode compatibility labels Jul 5, 2019
@JPinkney JPinkney force-pushed the vscode-keys3 branch 2 times, most recently from 9d50407 to 2b74fd1 Compare July 8, 2019 12:17
@JPinkney
Copy link
Contributor Author

JPinkney commented Jul 8, 2019

@vince-fugnitto I've fixed the issue with the reset!

@vince-fugnitto
Copy link
Member

@vince-fugnitto I've fixed the issue with the reset!

Great! I'll try it out :)

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the keybindings-widget revert functionality, it all works correctly now thank you!
@akosyakov the comment I had about the revert has been addressed.

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed code. It looks good except one place can be simplified.

@akosyakov
Copy link
Member

@tsmaeder can you nominate @JPinkney as a Theia committer please that he can merge, open CQs and so on as well

Signed-off-by: Josh Pinkney <joshpinkney@gmail.com>
@JPinkney
Copy link
Contributor Author

@akosyakov I don't think @tsmaeder has nominated me but I've fixed up your comment and it should be ready for merge

@akosyakov akosyakov merged commit 1f9472e into eclipse-theia:master Jul 16, 2019
kittaakos added a commit that referenced this pull request Jul 22, 2019
This reverts commit 1f9472e.

Reverts #5326.
Closes #5749.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
kittaakos pushed a commit that referenced this pull request Jul 23, 2019
This reverts commit 1f9472e.

Reverts #5326.
Closes #5749.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
kittaakos pushed a commit that referenced this pull request Jul 23, 2019
This reverts commit 1f9472e.

Reverts #5326.
Closes #5749.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keybindings issues related to keybindings vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants